package github.sf.fw.tools.cmd;

import java.util.Objects;

public class CmdOption {
    private final String name;
    private final String expr;
    private final String aliasExpr;
    private final String description;

    private CPC cpc = CPC.BLANK;


    public CmdOption(String name, String expr, CPC cpc) {
        this(name, expr, null, null, cpc);
    }

    public CmdOption(String name, String expr, CPC cpc, String description) {
        this(name, expr, null, description, cpc);
    }

    public CmdOption(String name, String expr, String aliasExpr, String description, CPC cpc) {
        this.name = name;
        this.expr = expr;
        this.aliasExpr = aliasExpr;
        this.description = description;
        if (cpc != null) {
            this.cpc = cpc;
        }
    }

    public String getName() {
        return name;
    }

    public String getExpr() {
        return expr;
    }

    public String getAliasExpr() {
        return aliasExpr;
    }

    public String getDescription() {
        return description;
    }

    public CPC getCpc() {
        return cpc;
    }

    public void setCpc(CPC cpc) {
        this.cpc = cpc;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        CmdOption cmdOption = (CmdOption) o;
        return name.equals(cmdOption.name) && expr.equals(cmdOption.expr) && aliasExpr.equals(cmdOption.aliasExpr);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, expr, aliasExpr);
    }

    public String getParameterConnector() {
        return cpc.getSymbol();
    }
}
